//河段模型边界
Ext.define("Admin.view.sys.DdsMBoundry", {
	extend: "Admin.common.container.BaseContainer",
	xtype: "ddsMBoundry",
	alias: "ddsMBoundry",
	requires: [
		"Ext.panel.Panel",
		"Ext.grid.Panel",
		"Ext.button.Button",
		"Admin.common.form.SearchFormPanel",
		"Admin.store.sys.DdsMBoundry",
	],
	controller: "ddsMBoundryController",
	layout: 'fit',
	width: '100%',
	height: 200,


	items: [{
			title: "河段模型边界",
			xtype: "baseGridPanel",
			reference: "riverMBGrid",
			width: '100%',
			border: true,
			columns: [{
					header: "污染发生河段",
					dataIndex: "rcd",
					align: "center",
					flex: 1,
					renderer: function (value, record) {
						return getRnm(value);
					}
				},
				{
					header: "边界名称",
					dataIndex: "bname",
					align: "center",
					flex: 1,
				},
				{
					header: "数值类型",
					dataIndex: "vtype",
					align: "center",
					flex: 1,
				},
				{
					header: "边界对应的测站",
					dataIndex: "stcd",
					align: "center",
					flex: 1,
				},
				{
					header: "边界对应的断面",
					dataIndex: "secnm",
					align: "center",
					flex: 1,
				},

				{
					header: "数据查询字段标识",
					dataIndex: "fieldnm",
					align: "center",
					flex: 1,
				},

				{
					header: "边界类型",
					dataIndex: "btype",
					align: "center",
					flex: 1,
				},
				{
					header: "河流标识",
					dataIndex: "river",
					align: "center",
					flex: 1,
					renderer: function (value, record) {
						if (value == '02') {
							return '抚河';
						} else {
							return '袁河';
						}
					}
				},
				{
					xtype: "actioncolumn",
					text: "操作",
					align: "center",
					width: 100,
					sortable: false,
					menuDisabled: true,
					items: [{
							iconCls: "x-fa fa-edit",
							tooltip: "编辑",
							handler: "riverUpdate"
						},
						{
							iconCls: "x-fa fa-times-circle",
							tooltip: "删除",
							handler: "riverDelete"
						}
					]
				}
			],
			store: {
				type: "ddsMBoundry"
			},
			tbar: [{
					xtype: "searchFormPanel",
					columns: 2,
					items: [{
						xtype: "dicComboBox",
						dicType: 'riverRcd',
						maxWidth: 300,
						fieldLabel: "污染发生河段",
						labelWidth: 100,
						reference: 'serchRcd',
						listeners: {
							added: function () {
								var store = this.getStore();
								store.clearFilter();
								store.filter({
									property: 'river',
									value: config.RIVER
								});
							}
						}
					}, ]
				},
				"->",
				{
					xtype: "button",
					iconCls: "x-fa fa-search",
					text: "查询",
					handler: "riverSearch"
				},
				{
					xtype: "button",
					iconCls: "x-fa fa-save",
					text: "新增",
					handler: "riverAdd"
				}
			],
			bbar: {
				xtype: "pagingtoolbar",
				autoLoad: true,
				displayInfo: true,
				displayMsg: "显示从第{0}条数据到第{1}条数据，共{2}条数据",
				emptyMsg: "没有记录"
			}
		},

	]
});


Ext.define("Admin.view.sys.RiverMBForm", {
	extend: 'Ext.form.Panel',
	// extend: "Admin.common.form.BaseFormPanel",
	xtype: "riverMBForm",
	alias: "riverMBForm",
	bodyPadding: 10,
	layout: "anchor",
	defaults: {
		anchor: "100%",
		labelWidth: 120,
		labelAlign: "right"
	},
	defaultType: "textfield",
	margin: "0 0 10 0",
	items: [{
			xtype: "combobox",
			fieldLabel: "污染发生河段",
			valueField: "rcd",
			displayField: "rnm",
			name: "rcd",
			disabled: false,
			emptyText: "请选择河段名称",
			reference: "riverRcd",
			listeners: {
				added: function (combo) {
					var _that = this;
					var store = Ext.create('Ext.data.Store', {
						fields: ['rnm', 'rcd'],
						data: mriverList
					});
					store.clearFilter();
					store.filter({
						property: 'river',
						value: config.RIVER
					});
					combo.setStore(store);
				},
				change: function (me, newVlaue, oldValue, eOpts) {
					var that = this;
					var riverRcd = that.getStore().getData().items;
					riverRcd.forEach(function (item) {
						if (newVlaue == item.data.rcd) {
							that.ownerCt.getForm().findField('river').setValue(item.data.river);
						}
					})
				}
			}
		},
		{
			fieldLabel: "边界名称",
			name: "bname",
			disabled: false,
			// listeners: {
			// 	blur: function (combo) {
			// 		var that = this;
			// 		that.ownerCt.getForm().findField('river').setValue(item.data.river);
			// 	}
			// }
		},

		{
			xtype: "combobox",
			fieldLabel: "数值类型",
			emptyText: "请选择数值类型",
			editable: false,
			disabled: false,
			allowBlank: false,
			name: "vtype",
			valueField: "vtype",
			displayField: "vtype",
			listeners: {
				added: function (combo) {
					var _that = this;
					var store = Ext.create('Ext.data.Store', {
						fields: ['vtype'],
						data: [{
							'vtype': '水位'
						}, {
							'vtype': '流量'
						}]
					});
					combo.setStore(store);
				}
			}
		},
		{
			fieldLabel: "边界对应的测站",
			// editable:false ,
			name: "stcd",
		},
		{
			fieldLabel: "边界对应的断面",
			// editable:false ,
			name: "secnm",
		},
		{
			xtype: "combobox",
			fieldLabel: "数据查询字段",
			emptyText: "请选择查询字段",
			editable: false,
			disabled: false,
			allowBlank: false,
			valueField: "fieldnm",
			displayField: "fieldnm",
			name: "fieldnm",
			listeners: {
				added: function (combo) {
					var _that = this;
					var store = Ext.create('Ext.data.Store', {
						fields: ['fieldnm'],
						data: [{
							'fieldnm': 'Q'
						}, {
							'fieldnm': 'Z'
						}, {
							'fieldnm': 'INQ'
						}, {
							'fieldnm': 'RZ'
						}]
					});
					combo.setStore(store);
				}
			}
		},
		{
			xtype: "combobox",
			emptyText: "请选择边界类型",
			editable: false,
			disabled: false,
			allowBlank: false,
			fieldLabel: "边界类型",
			valueField: "btype",
			displayField: "btype",
			name: "btype",
			listeners: {
				added: function (combo) {
					var _that = this;
					var store = Ext.create('Ext.data.Store', {
						fields: ['btype'],
						data: [{
							'btype': '上边界'
						}, {
							'btype': '下边界'
						}, {
							'btype': '水库'
						}, {
							'btype': '支流'
						}]
					});
					combo.setStore(store);
				}
			}
		},
		{
			fieldLabel: "河流标识",
			editable: false,
			name: "river",
		},
	]
});